﻿//********************************************************************************//
//创建日期：<创建日期，2016-03-31>
//创建作者：<郭登杰，guodengjie@shanghai3h.com>
//功能说明：账单信息Model
//********************************************************************************//
using System;
using System.Collections.Generic;
using YXYLCommon;
using System.Data;

namespace Entity
{
    [Serializable]
    /// <summary>
    /// 发票库存
    /// </summary>
    public class QSSFZhangDanXX : BaseModel
    {
        public QSSFZhangDanXX()
        {
          
        }

        public int I_ZHUANGTAI { get; set; }
        public string I_ZHUANGTAI_STR
        {
            get
            {
                return this.I_ZHUANGTAI==1?"成功":"打坏";
            }
        }

        public string S_SHUIBIAOBH { get; set; }
        public string S_ZHANGDANBH { get; set; }

        public string S_YONGHUH { get; set; }

        public string S_YONGHUM { get; set; }

        public DbInt I_YM { get; set; }
        public string I_YM_STR {
            get
            {
                return this.I_YM.ValueString;
            }
        }

        public decimal N_JINE { get; set; }
        public string N_JINE_STR { get { return this.N_JINE.ToString("0.00"); } }

        public string S_KAIHUHM { get; set; }

        public string S_KAIHUYH { get; set; }

        public string S_KAIHUZH { get; set; }

        public string S_FAPIAOHM { get; set; }

        public DbDateTime D_DAYINRQ { get; set; }
        public string D_DAYINRQ_STR { get { return this.D_DAYINRQ.DateString; } }

        public decimal N_SHUIJIA { get; set; }
        public string N_SHUIJIA_STR { get { return this.N_SHUIJIA.ToString("0.00"); } }

        public DbInt I_YSL { get; set; }
        public string I_YSL_STR
        {
            get
            {
                return this.I_YSL.ValueString;
            }
        }

        public override BaseModel ToObject(System.Data.DataRow row)
        {
            this.IsExists = true;
            this.I_ZHUANGTAI = Convert.ToInt32(row["I_ZHUANGTAI"]);
            this.S_ZHANGDANBH = Convert.ToString(row["S_ZHANGDANBH"]);
            this.S_YONGHUH = Convert.ToString(row["S_YONGHUH"]);
            this.S_YONGHUM = Convert.ToString(row["S_YONGHUM"]);
            this.I_YM = row.Table.Columns.Contains("I_YM") ? DbInt.Parse(row["I_YM"]) : DbInt.Parse(null);
            this.N_JINE = Convert.ToDecimal(row["N_JINE"]);
            this.N_SHUIJIA = row.Table.Columns.Contains("N_SHUIJIA") ? Convert.ToDecimal(row["N_SHUIJIA"]) : 0;
            this.S_KAIHUHM = Convert.ToString(row["S_KAIHUHM"]);
            this.S_KAIHUYH = Convert.ToString(row["S_KAIHUYH"]);
            this.S_KAIHUZH = Convert.ToString(row["S_KAIHUZH"]);
            this.S_FAPIAOHM = Convert.ToString(row["S_FAPIAOHM"]);
            this.D_DAYINRQ = row.Table.Columns.Contains("D_DAYINRQ") ? DbDateTime.Parse(row["D_DAYINRQ"]) : DbDateTime.Parse(null);
            this.S_SHUIBIAOBH = row.Table.Columns.Contains("S_SHUIBIAOBH") ? Convert.ToString(row["S_SHUIBIAOBH"]) : null;
            this.I_YSL = row.Table.Columns.Contains("I_YSL") ? DbInt.Parse(row["I_YSL"]) : DbInt.Parse(null);
            return this;
        }
    }
    public class DALQSSFZhangDanXX : BaseDAL
    {
        public DALQSSFZhangDanXX()
        {

        }
        protected override void fillSaveProc(BaseModel model)
        {
            
        }

        public List<QSSFZhangDanXX> Get(int type,string yonghuh,int y1,int y2)
        {
            dbProc.Init("P_QSSF_DAYINZDXXHQ");
            dbProc.AddParameter("V_TYPE",type);
            dbProc.AddParameter("V_YONGHUH", yonghuh);
            dbProc.AddParameter("V_Y1", y1);
            dbProc.AddParameter("V_Y2", y2);
            return CommonService.Ini().GetList<QSSFZhangDanXX>(dbProc);
        }
        /// <summary>
        /// 获取已打印账单信息
        /// </summary>
        /// <param name="zt">打印状态 0:全部 1:成功 2:打坏</param>
        /// <param name="ym">水量年月</param>
        /// <param name="hm">发票或费用编号</param>
        /// <param name="printdate">打印日期</param>
        public List<QSSFZhangDanXX> Get2(int zt, int ym, string hm, DbDateTime printdate)
        {
            dbProc.Init("P_QSSF_DAYINZDXXHQ2_DXS");
            dbProc.AddParameter("V_ZHUANGTAI", zt);
            dbProc.AddParameter("V_YM", ym);
            dbProc.AddParameter("V_HM", hm);
            dbProc.AddParameter("V_PRINTDATE", printdate.TimeDBParameter);
            return CommonService.Ini().GetList<QSSFZhangDanXX>(dbProc);
        }

        /// <summary>
        /// 发票打印状态变更
        /// </summary>
        /// <param name="zt">1:成功  2:打坏 0:未打印</param>
        /// <param name="fphms">发票号码s</param>
        public DbCmdResult DaYinZTBG(int zt, string fphms)
        {
            dbProc.Init("P_QSSF_ZDDYZTBG_DXS");
            dbProc.AddParameter("V_ZHUANGTAI", zt);
            dbProc.AddParameter("V_FAPIAOHMS", fphms);
            return CommonService.Ini().ExcuteProcOracle(dbProc);
        }
        public List<QSSFZhangDanDYTJ> DaYinTJGet(DbDateTime printdate)
        {
            dbProc.Init("P_QSSF_ZDDYTJ_DXS");
            dbProc.AddParameter("V_PRINTDATE", printdate.TimeDBParameter);
            return CommonService.Ini().GetList<QSSFZhangDanDYTJ>(dbProc);
        }
    }

}